package com.woniuxy.vuecli.controller;

import com.woniuxy.vuecli.entity.ResponseResult;
import com.woniuxy.vuecli.entity.Role;
import com.woniuxy.vuecli.entity.RoleMenuDTO;
import com.woniuxy.vuecli.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author author
 * @Create 2024-01-15 10:09
 */
//@CrossOrigin
@RequestMapping("/role")
@RestController
public class RoleController {

    @Autowired
    RoleService roleService;


    @RequestMapping("/getAll")
    public ResponseResult<List<Role>> getAll(){
        return new ResponseResult<>(200,"ok", roleService.getAll());
    }

    @RequestMapping("/addMenu")
    public ResponseResult<Void> addMenu(@RequestBody RoleMenuDTO roleMenuDTO){
        roleService.addMenu(roleMenuDTO.getRid(), roleMenuDTO.getMids());
        return new ResponseResult<>(200,"ok", null);
    }
}
